home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d17 / ansprn.arc / ANSPRN.INC next >
Text File  |  1991-08-13  |  2KB  |  67 lines

  1. 'ANSI Print for PowerBASIC
  2. 'CopyRight 1991 by Dave Navarro, Jr. - All Rights Reserved
  3. 'For questions, leave me a message on The Bard's Lair (718) 381-3651
  4.  
  5. 'AnsiPrint() will display a string through DOS's PRINCHAR function
  6. 'which handles ANSI codes (if ANSI.SYS or equivalant is installed)
  7. 'It also tests for the cursor position and keeps the specified number of
  8. 'lines on the bottom of the screen from being overwritten.
  9.  
  10. $CPU 8086
  11. $ERROR ALL OFF
  12. $LIB ALL OFF
  13. $COMPILE UNIT
  14.  
  15. SUB AnsiPrint(Text$,Lins%) PUBLIC
  16.    REPLACE CHR$(27)+"[2J" WITH CHR$(12) IN Text$
  17.    FOR I%=1 TO LEN(Text$)
  18.      Tmp$=MID$(Text$,I%,1)
  19.      IF Tmp$=CHR$(12) THEN
  20.        CALL ScrollUp(1,80,1,Lins%,0,CurColor%)
  21.        LOCATE 1,1
  22.        GOTO ControlChar
  23.      END IF
  24.      CALL DPrintChar(Tmp$)
  25.      IF DCSRLIN%>Lins% THEN
  26.        LOCATE Lins%,DPOS%
  27.        CALL ScrollUp(1,80,1,Lins%,1,CurColor%)
  28.      END IF
  29.      ControlChar:
  30.    NEXT I%
  31.    LOCATE DCSRLIN%,DPOS%,1
  32. END SUB
  33.  
  34. FUNCTION CurColor%
  35.   CurColor%=SCREEN(DCSRLIN%,DPOS%,1)
  36. END FUNCTION
  37.  
  38. 'ScrollUp - Scroll a specified part of the screen up
  39.  
  40. SUB ScrollUp (LC%, RC%, TR%, BR%, Rows%, Atr%)
  41.    REG 1, Rows%+256*6
  42.    REG 2, Atr%*256
  43.    REG 3, (LC%-1)+(256*(TR%-1))
  44.    REG 4, (RC%-1)+(256*(BR%-1))
  45.    CALL INTERRUPT &h10
  46. END SUB
  47.  
  48. SUB DPrintChar(Char$)
  49.   REG 1, &h0200
  50.   REG 4, ASC(Char$)
  51.   CALL INTERRUPT &h21
  52. END SUB
  53.  
  54. FUNCTION DCSRLIN% PUBLIC
  55.     REG 1,&H0300
  56.     REG 2,&H0000
  57.     CALL INTERRUPT &H10
  58.     DCSRLIN%=(REG(4) AND &HFF00)/256+1
  59. END FUNCTION
  60.  
  61. FUNCTION DPOS% PUBLIC
  62.     REG 1,&H0300
  63.     REG 2,&H0000
  64.     CALL INTERRUPT &H10
  65.     DPOS%=(REG(4) AND &H00FF)+1
  66. END FUNCTION
  67.